﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace _TListBox {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e) {
            TListItemGroup tGroup = tListBox1.AddGroup(Properties.Resources.音量, "测试1",Color.Red);
            tGroup.OnClicked += TGroup_OnClicked;
            tGroup.AddItem(Properties.Resources.音量, "子项目1");
            tGroup.AddItem(Properties.Resources.音量, "子项目1");
            tGroup.AddItem(Properties.Resources.音量, "子项目1");
            tGroup.AddItem(Properties.Resources.音量, "子项目1");
            tGroup.AddItem(Properties.Resources.音量, "子项目1");

            tGroup = tListBox1.AddGroup(Properties.Resources.音量, "测试2",Color.Blue);
            tGroup.OnClicked += TGroup_OnClicked;
            tGroup.AddItem(Properties.Resources.音量, "dsfsdf");
            tGroup.AddItem(Properties.Resources.音量, "子项目1");
            tGroup.AddItem(Properties.Resources.音量, "子项目1");
            tGroup.AddItem(Properties.Resources.音量, "子项目1");

            tGroup = tListBox1.AddGroup(Properties.Resources.音量, "测试3",Color.Green);
            tGroup.OnClicked += TGroup_OnClicked;
            tGroup.AddItem(Properties.Resources.音量, "dsfsdf");

            tGroup = tListBox1.AddGroup(Properties.Resources.音量, "测试4",Color.Black);
            tGroup.OnClicked += TGroup_OnClicked;
            tGroup.AddItem(Properties.Resources.音量, "dsfsdf");
            tGroup.AddItem(Properties.Resources.音量, "dsfsdf");
            tGroup.AddItem(Properties.Resources.音量, "dsfsdf");
            tGroup.AddItem(Properties.Resources.音量, "dsfsdf");
            tGroup.AddItem(Properties.Resources.音量, "dsfsdf");
            tGroup.AddItem(Properties.Resources.音量, "dsfsdf");
            tGroup.AddItem(Properties.Resources.音量, "dsfsdf");
            tGroup.AddItem(Properties.Resources.音量, "dsfsdf");
            tGroup.AddItem(Properties.Resources.音量, "dsfsdf");
            tGroup.AddItem(Properties.Resources.音量, "dsfsdf");
            tGroup.AddItem(Properties.Resources.音量, "dsfsdf");
            tGroup.AddItem(Properties.Resources.音量, "dsfsdf");
            tGroup.AddItem(Properties.Resources.音量, "dsfsdf");

        }

        private void TGroup_OnClicked(TListItemGroup arg1, int row) {
            TListItem tItem = arg1.GetItem(row);
            if (row == 0) {
                label1.Text=("点击了标题:" + tItem.text);
            }
            else {
                label1.Text = ("点击了子项目:" + tItem.text);
            }
        }
    }
}
